#!/bin/sh
set -ex
function getip(){
  curl -sSL http://ip.clearcode.cn
}

function setip() {
  curl -sSL "http://ip.clearcode.cn/kv?k=ip&v=${1}"
}

while :
do
  sleep $1
  ip=$(getip)
  setip $ip > /dev/null
  echo "set ip ${ip}"
done
